package ru.mcfr.oxygen.framework.operations.highlight;

import ro.sync.ecss.extensions.api.*;
import ro.sync.ecss.extensions.api.highlights.AuthorPersistentHighlighter;

/**
 * Operation used to remove all persistent highlights.
 */
public class RemoveAllHighlightsOperation implements AuthorOperation {

    /**
     * @see ro.sync.ecss.extensions.api.AuthorOperation#doOperation(ro.sync.ecss.extensions.api.AuthorAccess, ro.sync.ecss.extensions.api.ArgumentsMap)
     */
    public void doOperation(AuthorAccess authorAccess, ArgumentsMap args)
            throws IllegalArgumentException, AuthorOperationException {
        AuthorPersistentHighlighter highlighter = authorAccess.getEditorAccess().getPersistentHighlighter();
        int highlights = highlighter.getHighlights().length;
        // Remove all highlights
        highlighter.removeAllHighlights();
        authorAccess.getWorkspaceAccess().showInformationMessage(highlights == 1 ? "1 highlight removed" : highlights + " highlights removed");
    }

    /**
     * @see ro.sync.ecss.extensions.api.AuthorOperation#getArguments()
     */
    public ArgumentDescriptor[] getArguments() {
        return null;
    }

    /**
     * @see ro.sync.ecss.extensions.api.Extension#getDescription()
     */
    public String getDescription() {
        return "Remove all persistent highlights";
    }

}
